package org.example.demo2.service;

import ch.qos.logback.core.util.StringUtil;
import org.example.demo2.common.PageData;
import org.example.demo2.common.ResponseData;
import org.example.demo2.pojo.UserInfo;
import org.example.demo2.pojo.UserQuery;
import org.springframework.stereotype.Service;

@Service
public class UserService implements IUserServiece{

    String symbol = "^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[!@#$%^&*()\\-_=+{};:,<.>\\/?]).{8,}$";

    @Override
    public ResponseData signUser(UserInfo userInfo){

        if("".equals(userInfo.getUserName()) || userInfo.getUserName() == null){
            return ResponseData.fail("用户名不能为空");
        }

        if("".equals(userInfo.getPwd())){
            return ResponseData.fail("密码不能为空");
        }

        if (userInfo.getPwd().length() <8) {
            return ResponseData.fail("密码长度必须大于8");
        }
        if (userInfo.getPwd().matches(symbol)) {
            return ResponseData.fail("密码必须包含特殊字符");
        }
        return ResponseData.success(userInfo);
    }

    @Override
    public ResponseData<PageData<UserInfo>> page(UserQuery userQuery) {
        return null;
    }
}
